package com.zr.userLive.service.impl;

import com.zr.userInfo.pojo.UserInfo;
import com.zr.userInfo.pojo.UserInfoAddVo;
import com.zr.userLive.mapper.UserLiveMapper;
import com.zr.userLive.pojo.UserLive;
import com.zr.userLive.pojo.UserLiveAddVo;
import com.zr.userLive.service.UserLiveService;
import com.zr.util.ResultBuildVo;
import com.zr.util.ResultVOBuilder;
import com.zr.util.ResultVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * Created by Administrator on 2019/7/3.
 */
@Service
public class UserLiveServiceImpl implements UserLiveService {

    @Autowired
    private UserLiveMapper userLiveMapper;

    @Override
    public ResultVo  userPicture(UserLiveAddVo userLiveAddVo) {
        UserLive userLive = new UserLive();
        Date nowDate = new Date();
        userLive.setCreateTime(nowDate);
        userLive.setCreateName("小明");
        userLive.setUpdateTime(nowDate);
        userLive.setUpdateName("小明");
        BeanUtils.copyProperties(userLiveAddVo, userLive);
//        userInfoAddVo.add(userInfo);

        userLiveMapper.userPicture(userLive);
        return ResultVOBuilder.success(userLive);
    }

    @Override
    public ResultVo queryLoginId(Integer loginId) {
        if (loginId == 0){
            return ResultVOBuilder.error("注册信息的ID不存在","500");
        }
        UserInfoAddVo userInfoAddVo = userLiveMapper.queryLoginId(loginId);
        return ResultVOBuilder.success(userInfoAddVo);
    }

    @Override
    public ResultVo queryByUserIfoid(Integer id) {
        UserInfo userInfo = userLiveMapper.queryByUserIfoid(id);
        return ResultBuildVo.success(userInfo);
    }
}
